1 <?php
2 // This script and data application were generated by AppGini 5.62
3 // Download AppGini for free from https://bigprof.com/appgini/download/
4
5 $currDir=dirname(__FILE__);
6 include("$currDir/defaultLang.php");
7 include("$currDir/language.php");
8 include("$currDir/lib.php");
9 @include("$currDir/hooks/patients.php");
10 include("$currDir/patients_dml.php");
11
12 // mm: can the current member access this page?
13 $perm=getTablePermissions('patients');
14 if(!$perm[0]){
15 echo error_message($Translation['tableAccessDenied'], false);
16 echo '<script>setTimeout("window.location=\'index.php?signOut=1\'", 2000);</script>';
17 exit;
18 }
19
20 $x = new DataList;
21 $x->TableName = "patients";
22
23 // Fields that can be displayed in the table view
24 $x->QueryFieldsTV = array(
25 "`patients`.`id`" => "id",
26 "`patients`.`last_name`" => "last_name",
27 "`patients`.`first_name`" => "first_name",
28 "`patients`.`gender`" => "gender",
29 "`patients`.`sexual_orientation`" => "sexual_orientation",
30 "if(`patients`.`birth_date`,date_format(`patients`.`birth_date`,'%m/%d/%Y'),'')" => "birth_date",
31 "`patients`.`age`" => "age",
32 "`patients`.`image`" => "image",
33 "`patients`.`address`" => "address",
34 "`patients`.`city`" => "city",
35 "`patients`.`state`" => "state",
36 "`patients`.`zip`" => "zip",
37 "CONCAT_WS('-', LEFT(`patients`.`home_phone`,3), MID(`patients`.`home_phone`,4,3), RIGHT(`patients`.`home_phone`,4))" => "home_phone",
38 "CONCAT_WS('-', LEFT(`patients`.`work_phone`,3), MID(`patients`.`work_phone`,4,3), RIGHT(`patients`.`work_phone`,4))" => "work_phone",
39 "CONCAT_WS('-', LEFT(`patients`.`mobile`,3), MID(`patients`.`mobile`,4,3))" => "mobile",
40 "`patients`.`tobacco_usage`" => "tobacco_usage",
41 "`patients`.`alcohol_intake`" => "alcohol_intake",
42 "`patients`.`history`" => "history",
43 "`patients`.`surgical_history`" => "surgical_history",
44 "`patients`.`obstetric_history`" => "obstetric_history",
45 "`patients`.`genetic_diseases`" => "genetic_diseases",
46 "`patients`.`contact_person`" => "contact_person",
47 "`patients`.`other_details`" => "other_details",
48 "`patients`.`comments`" => "comments",
49 "DATE_FORMAT(`patients`.`filed`, '%c/%e/%Y %l:%i%p')" => "filed",
50 "DATE_FORMAT(`patients`.`last_modified`, '%c/%e/%Y %l:%i%p')" => "last_modified"
51 );
52 // mapping incoming sort by requests to actual query fields
53 $x->SortFields = array(
54 1 => '`patients`.`id`',
55 2 => 2,
56 3 => 3,
57 4 => 4,
58 5 => 5,
59 6 => '`patients`.`birth_date`',
60 7 => '`patients`.`age`',
61 8 => 8,
62 9 => 9,
63 10 => 10,
64 11 => 11,
65 12 => 12,
66 13 => 13,
67 14 => 14,
68 15 => 15,
69 16 => 16,
70 17 => 17,
71 18 => 18,
72 19 => 19,
73 20 => 20,
74 21 => 21,
75 22 => 22,
76 23 => 23,
77 24 => 24,
78 25 => '`patients`.`filed`',
79 26 => '`patients`.`last_modified`'
80 );
81
82 // Fields that can be displayed in the csv file
83 $x->QueryFieldsCSV = array(
84 "`patients`.`id`" => "id",
85 "`patients`.`last_name`" => "last_name",
86 "`patients`.`first_name`" => "first_name",
87 "`patients`.`gender`" => "gender",
88 "`patients`.`sexual_orientation`" => "sexual_orientation",
89 "if(`patients`.`birth_date`,date_format(`patients`.`birth_date`,'%m/%d/%Y'),'')" => "birth_date",
90 "`patients`.`age`" => "age",
91 "`patients`.`image`" => "image",
92 "`patients`.`address`" => "address",
93 "`patients`.`city`" => "city",
94 "`patients`.`state`" => "state",
95 "`patients`.`zip`" => "zip",
96 "CONCAT_WS('-', LEFT(`patients`.`home_phone`,3), MID(`patients`.`home_phone`,4,3), RIGHT(`patients`.`home_phone`,4))" => "home_phone",
97 "CONCAT_WS('-', LEFT(`patients`.`work_phone`,3), MID(`patients`.`work_phone`,4,3), RIGHT(`patients`.`work_phone`,4))" => "work_phone",
98 "CONCAT_WS('-', LEFT(`patients`.`mobile`,3), MID(`patients`.`mobile`,4,3))" => "mobile",
99 "`patients`.`tobacco_usage`" => "tobacco_usage",
100 "`patients`.`alcohol_intake`" => "alcohol_intake",
101 "`patients`.`history`" => "history",
102 "`patients`.`surgical_history`" => "surgical_history",
103 "`patients`.`obstetric_history`" => "obstetric_history",
104 "`patients`.`genetic_diseases`" => "genetic_diseases",
105 "`patients`.`contact_person`" => "contact_person",
106 "`patients`.`other_details`" => "other_details",
107 "`patients`.`comments`" => "comments",
108 "DATE_FORMAT(`patients`.`filed`, '%c/%e/%Y %l:%i%p')" => "filed",
109 "DATE_FORMAT(`patients`.`last_modified`, '%c/%e/%Y %l:%i%p')" => "last_modified"
110 );
111 // Fields that can be filtered
112 $x->QueryFieldsFilters = array(
113 "`patients`.`id`" => "ID",
114 "`patients`.`last_name`" => "Last name",
115 "`patients`.`first_name`" => "First name",
116 "`patients`.`gender`" => "Gender",
117 "`patients`.`sexual_orientation`" => "Sexual orientation",
118 "`patients`.`birth_date`" => "Birth date",
119 "`patients`.`age`" => "Age",
120 "`patients`.`address`" => "Address",
121 "`patients`.`city`" => "City",
122 "`patients`.`state`" => "State",
123 "`patients`.`zip`" => "Zip",
124 "`patients`.`home_phone`" => "Home phone",
125 "`patients`.`work_phone`" => "Work phone",
126 "`patients`.`mobile`" => "Mobile",
127 "`patients`.`tobacco_usage`" => "Tobacco usage",
128 "`patients`.`alcohol_intake`" => "Alcohol Intake",
129 "`patients`.`history`" => "History",
130 "`patients`.`surgical_history`" => "Surgical history",
131 "`patients`.`obstetric_history`" => "Obstetric history",
132 "`patients`.`genetic_diseases`" => "Genetic diseases",
133 "`patients`.`contact_person`" => "Contact person in case of Emergency",
134 "`patients`.`other_details`" => "Other details",
135 "`patients`.`comments`" => "Comments",
136 "`patients`.`filed`" => "Filed",
137 "`patients`.`last_modified`" => "Last modified"
138 );
139
140 // Fields that can be quick searched
141 $x->QueryFieldsQS = array(
142 "`patients`.`id`" => "id",
143 "`patients`.`last_name`" => "last_name",
144 "`patients`.`first_name`" => "first_name",
145 "`patients`.`gender`" => "gender",
146 "`patients`.`sexual_orientation`" => "sexual_orientation",
147 "if(`patients`.`birth_date`,date_format(`patients`.`birth_date`,'%m/%d/%Y'),'')" => "birth_date",
148 "`patients`.`age`" => "age",
149 "`patients`.`address`" => "address",
150 "`patients`.`city`" => "city",
151 "`patients`.`state`" => "state",
152 "`patients`.`zip`" => "zip",
153 "CONCAT_WS('-', LEFT(`patients`.`home_phone`,3), MID(`patients`.`home_phone`,4,3), RIGHT(`patients`.`home_phone`,4))" => "home_phone",
154 "CONCAT_WS('-', LEFT(`patients`.`work_phone`,3), MID(`patients`.`work_phone`,4,3), RIGHT(`patients`.`work_phone`,4))" => "work_phone",
155 "CONCAT_WS('-', LEFT(`patients`.`mobile`,3), MID(`patients`.`mobile`,4,3))" => "mobile",
156 "`patients`.`tobacco_usage`" => "tobacco_usage",
157 "`patients`.`alcohol_intake`" => "alcohol_intake",
158 "`patients`.`history`" => "history",
159 "`patients`.`surgical_history`" => "surgical_history",
160 "`patients`.`obstetric_history`" => "obstetric_history",
161 "`patients`.`genetic_diseases`" => "genetic_diseases",
162 "`patients`.`contact_person`" => "contact_person",
163 "`patients`.`other_details`" => "other_details",
164 "`patients`.`comments`" => "comments",
165 "DATE_FORMAT(`patients`.`filed`, '%c/%e/%Y %l:%i%p')" => "filed",
166 "DATE_FORMAT(`patients`.`last_modified`, '%c/%e/%Y %l:%i%p')" => "last_modified"
167 );
168
169 // Lookup fields that can be used as filterers
170 $x->filterers = array();
171
172 $x->QueryFrom = "`patients` ";
173 $x->QueryWhere = '';
174 $x->QueryOrder = '';
175
176 $x->AllowSelection = 1;
177 $x->HideTableView = ($perm[2]==0 ? 1 : 0);
178 $x->AllowDelete = $perm[4];
179 $x->AllowMassDelete = false;
180 $x->AllowInsert = $perm[1];
181 $x->AllowUpdate = $perm[3];
182 $x->SeparateDV = 1;
183 $x->AllowDeleteOfParents = 1;
184 $x->AllowFilters = 1;
185 $x->AllowSavingFilters = 1;
186 $x->AllowSorting = 1;
187 $x->AllowNavigation = 1;
188 $x->AllowPrinting = 1;
189 $x->AllowCSV = 1;
190 $x->RecordsPerPage = 20;
191 $x->QuickSearch = 1;
192 $x->QuickSearchText = $Translation["quick search"];
193 $x->ScriptFileName = "patients_view.php";
194 $x->RedirectAfterInsert = "patients_view.php?SelectedID=#ID#";
195 $x->TableTitle = "Patients";
196 $x->TableIcon = "resources/table_icons/administrator.png";
197 $x->PrimaryKey = "`patients`.`id`";
198 $x->DefaultSortField = '1';
199 $x->DefaultSortDirection = 'desc';
200
201 $x->ColWidth = array( 120, 120, 70, 150, 50, 150, 50, 100, 150, 150, 150, 150, 150, 150);
202 $x->ColCaption = array("Last name", "First name", "Gender", "Sexual orientation", "Age", "Image", "State", "Mobile", "Tobacco usage", "Alcohol Intake", "History", "Surgical history", "Obstetric history", "Genetic diseases");
203 $x->ColFieldName = array('last_name', 'first_name', 'gender', 'sexual_orientation', 'age', 'image', 'state', 'mobile', 'tobacco_usage', 'alcohol_intake', 'history', 'surgical_history', 'obstetric_history', 'genetic_diseases');
204 $x->ColNumber = array(2, 3, 4, 5, 7, 8, 11, 15, 16, 17, 18, 19, 20, 21);
205
206 // template paths below are based on the app main directory
207 $x->Template = 'templates/patients_templateTV.html';
208 $x->SelectedTemplate = 'templates/patients_templateTVS.html';
209 $x->TemplateDV = 'templates/patients_templateDV.html';
210 $x->TemplateDVP = 'templates/patients_templateDVP.html';
211
212 $x->ShowTableHeader = 1;
213 $x->ShowRecordSlots = 0;
214 $x->TVClasses = "";
215 $x->DVClasses = "";
216 $x->HighlightColor = '#FFF0C2';
217
218 // mm: build the query based on current member's permissions
219 $DisplayRecords = $_REQUEST['DisplayRecords'];
220 if(!in_array($DisplayRecords, array('user', 'group'))){ $DisplayRecords = 'all'; }
221 if($perm[2]==1 || ($perm[2]>1 && $DisplayRecords=='user' && !$_REQUEST['NoFilter_x'])){ // view owner only
222 $x->QueryFrom.=', membership_userrecords';
223 $x->QueryWhere="where `patients`.`id`=membership_userrecords.pkValue and membership_userrecords.tableName='patients' and lcase(membership_userrecords.memberID)='".getLoggedMemberID()."'";
224 }elseif($perm[2]==2 || ($perm[2]>2 && $DisplayRecords=='group' && !$_REQUEST['NoFilter_x'])){ // view group only
225 $x->QueryFrom.=', membership_userrecords';
226 $x->QueryWhere="where `patients`.`id`=membership_userrecords.pkValue and membership_userrecords.tableName='patients' and membership_userrecords.groupID='".getLoggedGroupID()."'";
227 }elseif($perm[2]==3){ // view all
228 // no further action
229 }elseif($perm[2]==0){ // view none
230 $x->QueryFields = array("Not enough permissions" => "NEP");
231 $x->QueryFrom = '`patients`';
232 $x->QueryWhere = '';
233 $x->DefaultSortField = '';
234 }
235 // hook: patients_init
236 $render=TRUE;
237 if(function_exists('patients_init')){
238 $args=array();
239 $render=patients_init($x, getMemberInfo(), $args);
240 }
241
242 if($render) $x->Render();
243
244 // hook: patients_header
245 $headerCode='';
246 if(function_exists('patients_header')){
247 $args=array();
248 $headerCode=patients_header($x->ContentType, getMemberInfo(), $args);
249 }
250 if(!$headerCode){
251 include_once("$currDir/header.php");
252 }else{
253 ob_start(); include_once("$currDir/header.php"); $dHeader=ob_get_contents(); ob_end_clean();
254 echo str_replace('<%%HEADER%%>', $dHeader, $headerCode);
255 }
256
257 echo $x->HTML;
258 // hook: patients_footer
259 $footerCode='';
260 if(function_exists('patients_footer')){
261 $args=array();
262 $footerCode=patients_footer($x->ContentType, getMemberInfo(), $args);
263 }
264 if(!$footerCode){
265 include_once("$currDir/footer.php");
266 }else{
267 ob_start(); include_once("$currDir/footer.php"); $dFooter=ob_get_contents(); ob_end_clean();
268 echo str_replace('<%%FOOTER%%>', $dFooter, $footerCode);
269 }
270 ?>